Example: The following example will add a data label to the xy scatter series. The data label added displays the y co-ordinate values for first series.
import com.cete.dynamicpdf.Document; import com.cete.dynamicpdf.Page; import com.cete.dynamicpdf.RgbColor; import com.cete.dynamicpdf.pageelements.charting.Chart; import com.cete.dynamicpdf.pageelements.charting.PlotArea; import com.cete.dynamicpdf.pageelements.charting.Title; import com.cete.dynamicpdf.pageelements.charting.XYScatterDataLabel; import com.cete.dynamicpdf.pageelements.charting.series.XYScatterSeries; public class MyClass{ public static void main(String args[]){ // Create a PDF Document Document document = new Document(); // Create a Page and add it to the document Page page = new Page(); document.getPages().add(page); // Create a chart Chart chart = new Chart(0, 0, 400, 200); // Get the default plot area from the chart PlotArea plotArea = chart.getPrimaryPlotArea(); // Create a Header title and add it to the chart Title tTitle = new Title("Player Height and Weight"); chart.getHeaderTitles().add(tTitle); // Create xyScatter series and add values to it XYScatterSeries xyScatterSeries1 = new XYScatterSeries("Team A"); xyScatterSeries1.getValues().add(112, 55); xyScatterSeries1.getValues().add(125, 60); xyScatterSeries1.getValues().add(138, 68); xyScatterSeries1.getValues().add(150, 73); xyScatterSeries1.getValues().add(172, 82); XYScatterSeries xyScatterSeries2 = new XYScatterSeries("Team B"); xyScatterSeries2.getValues().add(110, 54); xyScatterSeries2.getValues().add(128, 62); xyScatterSeries2.getValues().add(140, 70); xyScatterSeries2.getValues().add(155, 75); xyScatterSeries2.getValues().add(170, 80); // Create xyscatter data label XYScatterDataLabel xyScatterDataLabel = new XYScatterDataLabel(true); xyScatterSeries1.setDataLabel( xyScatterDataLabel); xyScatterDataLabel.setColor(RgbColor.getRed()); // add xyScatter series to the plot Area plotArea.getSeries().add(xyScatterSeries1); plotArea.getSeries().add(xyScatterSeries2); // Create axis titles and add it to the axis Title title1 = new Title("Height (Inches)"); Title title2 = new Title("Weight (Pounds)"); xyScatterSeries1.getYAxis().getTitles().add(title1); xyScatterSeries1.getXAxis().getTitles().add(title2); // add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf" ); } }